package com.openspring.framework.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;

import com.openspring.platform.model.LoginUser;

public class ShiroUtils {

	public static LoginUser getUser() {
		Subject sub = SecurityUtils.getSubject();
		PrincipalCollection pc = sub.getPrincipals();
		if(pc == null)
			throw new RuntimeException("用户未登录");
		LoginUser loginUser = (LoginUser)pc.fromRealm("ShiroJdbcRealm").iterator().next();
		return loginUser;
	}
	
}
